package com.Controller.Admin;

import com.Common.CodeMsg;
import com.Common.ResultModel;
import com.Model.Admin.UserInfo;
import com.Params.UserInfoParams;
import com.Service.Admin.UserInfoService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;

@Controller
public class UserInfoController {
    @Autowired
    UserInfoService userInfoService;


    @RequestMapping(value = "/admin/userInfoIndex")
    public String index()
    {
        return "admin/UserInfo";
    }


    @RequestMapping(value = "/admin/UserInfo")
    @ResponseBody
    public ResultModel userInfo(UserInfo userInfo) {

        ResultModel ret = new ResultModel();
        ret.setCode(0);


        return ret;
    }

    @RequestMapping(value = "/admin/allUserInfo", method = RequestMethod.GET)
    @ResponseBody
    public ResultModel userInfo(UserInfoParams userParams) throws IOException {

        PageInfo<UserInfo> lst = userInfoService.userLSt(userParams);
        ResultModel resultModel;
        if (lst == null) {
            resultModel = new ResultModel(CodeMsg.nonData.getIndex(), CodeMsg.nonData.getName(), null);
        } else {
            resultModel = new ResultModel(CodeMsg.success.getIndex(), CodeMsg.success.getName(), lst.getList());
        }

        return resultModel;
    }

}